(function(){
	
	window.MUSIC_API = {
		KUWO_TYPE : 0,
		QQ_TYPE : 1
	};
	
	var host = "localhost",
		port = "8080",
		appName = "mcd",
		apiUrl = "http://"+host+":"+port+"/"+appName,
		searchUrl = apiUrl + "/music/search",
		storeUrl = apiUrl + "/music/store",
		removeUrl = apiUrl + "/music/remove";
	
	function jsonp(url,param,callback){
		$.ajax({
			url:url,			
			dataType:"jsonp",
			data:param,
			success:function(json){
				callback && callback(json);
			}
		});		
	}
	
	function _search(a,b){
		var l = arguments.length;
		if ( l == 1 ){
			if ($.isFunction(a)){
				jsonp(searchUrl,null,a);
			}
		}else if ( l == 2){
			if ($.isPlainObject(a) && $.isFunction(b) ){
				jsonp(searchUrl,a,b);
			}		
		}
	}
	
	function _store(music,b){
		jsonp(storeUrl,music,b);
	}
	
	function _remove(ids,b){
		jsonp(removeUrl,{ids:ids},b);
	}
	
	$.extend(window.MUSIC_API,{
		search:_search,
		store:_store,
		remove:_remove
	});
	
})();
